package com.spring.service.user;

import java.util.List;

import com.spring.domain.User;


public class UserImpl implements IUser{

	private JdbcUserDao dao;
	
	public List<User> getUsers() {
		return dao.getUsers();
	}

	public int insert(User user) {
		if(user!=null){
			return dao.insertUser(user);
		}
		return 0;
	}
	
	public User getUserById(int id){
		if(id!=0)
			return (User)dao.selectById(id);
		else
			return null;
		
	}
	
	public void delete(List<User> users) {
		if(!users.isEmpty())
			dao.deleteUser(users);
	}
	

	public JdbcUserDao getDao() {
		return dao;
	}

	public void setDao(JdbcUserDao dao) {
		this.dao = dao;
	}

	
	public void update(User user) {
		if(user!=null)
			dao.updateUser(user);
	}

	public List<User> getUserByMail(User user) {
		return dao.selectByMail(user);
	}

	public User login(String userName, String pwd) {
		return dao.login(userName,pwd);
	}

}
